

//
//  MenusSelectVC.m
//  WMZDialog
//
//  Created by wmz on 2019/7/9.
//  Copyright © 2019年 wmz. All rights reserved.
//

#import "MenusSelectVC.h"
#import "WMZDialog.h"
@interface MenusSelectVC ()
{
    WMZDialog * alert;
}
@end

@implementation MenusSelectVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.dataArr = @[@"一级",@"二级",@"三级(带打钩)",@"四级"];
}


- (void)action:(UIButton*)sender{
    @DialogWeakify(self)
    alert =  Dialog();
    id data = nil;
    if (sender.tag == 0) {
        data = [self getArr];
    } else if (sender.tag == 1) {
        data = [self getArr1];
    }else if (sender.tag == 2) {
        data = [self getArr2];
    }else{
        data = [self getArr3];
    }
    
    alert
    //下拉无限级菜单选中事件
    .wEventMenuClickSet( ^(id anyID, NSInteger section, NSInteger row) {
        //外部更新数据
      @DialogStrongify(self)
      [self selectMenu:section withRow:row];
      NSLog(@"菜单点击方法 当前选中值:%@ 当前选中列:%ld 当前选中行:%ld",anyID,(long)section,(long)row);
    })
    .wTypeSet(DialogTypeMenusSelect)
    .wDataSet(data);
    
    if (sender.tag == 2) {
        //带打钩
        alert.wSelectShowCheckedSet(YES)
        .wTextAlignmentSet(NSTextAlignmentLeft);
    }
    if (sender.tag == 1) {
        //改变出现的位置
        alert.wTapViewSet(sender);
        
    }
    alert.wStart();
    
}

- (void)selectMenu:(NSInteger)section withRow:(NSInteger)row{
    //刷新下一列显示的数据 用于从外部传入数据
    if (section == 1) {
        
        [alert updateMenuChildrenDataWithSection:section+1 withUpdateChildren:NO withData:@[
                                                                                            @{
                                                                                                @"name":[NSString stringWithFormat:@"好借好还就1111%ld_%ld",(long)section+1,(long)row],
                                                                                                @"id":@"111",
                                                                                                },
                                                                                            @{
                                                                                                @"name":[NSString stringWithFormat:@"%ld_%ld",(long)section+1,(long)row],
                                                                                                @"id":@"112",
                                                                                                },
                                                                                            @{
                                                                                                @"name":[NSString stringWithFormat:@"%ld_%ld",(long)section+1,(long)row],
                                                                                                @"id":@"113",
                                                                                                },
                                                                                            ]];
    }
}

//三层
- (NSArray*)getArr2{
    return @[
        @{
            @"name":@"数据2",
            @"id":@"2",
            @"children":@[]
            },
             @{
                 @"name":@"数据1",
                 @"id":@"1",
                 @"children":@[
                         @{
                             @"name":@"数据11",
                             @"id":@"11",
                             @"children":@[
                                     @{
                                         @"name":@"数据111",
                                         @"id":@"111",
                                         @"children":@[]
                                         },
                                     @{
                                         @"name":@"数据112",
                                         @"id":@"112",
                                         @"children":@[]
                                         },
                                     @{
                                         @"name":@"数据113",
                                         @"id":@"113",
                                         @"children":@[]
                                         },
                                     ]
                             },
                         @{
                             @"name":@"数据12",
                             @"id":@"12",
                             @"children":@[
                                     @{
                                         @"name":@"数据121",
                                         @"id":@"121",
                                         @"children":@[]
                                         },
                                     @{
                                         @"name":@"数据122",
                                         @"id":@"122",
                                         @"children":@[]
                                         },
                                     @{
                                         @"name":@"数据123",
                                         @"id":@"123",
                                         @"children":@[]
                                         },
                                     ]
                             },
                         @{
                             @"name":@"数据13",
                             @"id":@"13",
                             @"children":@[
                                     @{
                                         @"name":@"数据131",
                                         @"id":@"131",
                                         @"children":@[]
                                         },
                                     @{
                                         @"name":@"数据132",
                                         @"id":@"132",
                                         @"children":@[]
                                         },
                                     @{
                                         @"name":@"数据133",
                                         @"id":@"133",
                                         @"children":@[]
                                         },
                                     ]
                             },
                         ]
                 },
             @{
                 @"name":@"数据3",
                 @"id":@"3",
                 @"children":@[
                         @{
                             @"name":@"数据31",
                             @"id":@"31",
                             @"children":@[
                                     @{
                                         @"name":@"数据311",
                                         @"id":@"311",
                                         @"children":@[]
                                         },
                                     @{
                                         @"name":@"数据312",
                                         @"id":@"312",
                                         @"children":@[]
                                         },
                                     @{
                                         @"name":@"数据313",
                                         @"id":@"313",
                                         @"children":@[]
                                         },
                                     ]
                             },
                         @{
                             @"name":@"数据32",
                             @"id":@"32",
                             @"children":@[]
                             },
                         @{
                             @"name":@"数据33",
                             @"id":@"33",
                             @"children":@[
                                     @{
                                         @"name":@"数据331",
                                         @"id":@"331",
                                         @"children":@[]
                                         },
                                     @{
                                         @"name":@"数据332",
                                         @"id":@"332",
                                         @"children":@[]
                                         },
                                     @{
                                         @"name":@"数据333",
                                         @"id":@"333",
                                         @"children":@[]
                                         },
                                     ]
                             },
                         ]
                 },
             ];
}

//一层
- (NSArray*)getArr{
    return @[
             @{
                 @"name":@"数据1",
                 @"id":@"1",
                 @"children":@[]
                 },
             @{
                 @"name":@"数据2",
                 @"id":@"2",
                 @"children":@[]
                 },
             @{
                 @"name":@"数据3",
                 @"id":@"3",
                 @"children":@[]
                 },
             ];
}

//两层
- (NSArray*)getArr1{
    return @[
             @{
                 @"name":@"数据1",
                 @"id":@"1",
                 @"children":@[
                         @{
                             @"name":@"数据11",
                             @"id":@"11",
                             @"children":@[]
                             },
                         @{
                             @"name":@"数据12",
                             @"id":@"12",
                             @"children":@[]
                             },
                         @{
                             @"name":@"数据13",
                             @"id":@"13",
                             @"children":@[]
                             },
                         ]
                 },
             @{
                 @"name":@"数据2",
                 @"id":@"2",
                 @"children":@[]
                 },
             @{
                 @"name":@"数据3",
                 @"id":@"3",
                 @"children":@[
                         @{
                             @"name":@"数据31",
                             @"id":@"31",
                             @"children":@[]
                             },
                         @{
                             @"name":@"数据32",
                             @"id":@"32",
                             @"children":@[]
                             },
                         @{
                             @"name":@"数据33",
                             @"id":@"33",
                             @"children":@[]
                             },
                         ]
                 },
             ];
}

//四层
- (NSArray*)getArr3{
    return @[
             @{
                 @"name":@"数据1",
                 @"id":@"1",
                 @"children":@[
                         @{
                             @"name":@"数据11",
                             @"id":@"11",
                             @"children":@[
                                     @{
                                         @"name":@"数据111",
                                         @"id":@"111",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1111",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1112",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1113",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据112",
                                         @"id":@"112",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1121",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1122",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1123",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据113",
                                         @"id":@"113",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     ]
                             },
                         @{
                             @"name":@"数据12",
                             @"id":@"12",
                             @"children":@[
                                     @{
                                         @"name":@"数据121",
                                         @"id":@"121",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据122",
                                         @"id":@"122",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据123",
                                         @"id":@"123",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     ]
                             },
                         @{
                             @"name":@"数据13",
                             @"id":@"13",
                             @"children":@[
                                     @{
                                         @"name":@"数据131",
                                         @"id":@"131",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据132",
                                         @"id":@"132",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据133",
                                         @"id":@"133",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     ]
                             },
                         ]
                 },
             @{
                 @"name":@"数据2",
                 @"id":@"2",
                 @"children":@[
                         @{
                             @"name":@"数据21",
                             @"id":@"21",
                             @"children":@[
                                     @{
                                         @"name":@"数据211",
                                         @"id":@"211",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据212",
                                         @"id":@"212",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据213",
                                         @"id":@"213",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     ]
                             },
                         @{
                             @"name":@"数据22",
                             @"id":@"22",
                             @"children":@[
                                     @{
                                         @"name":@"数据221",
                                         @"id":@"221",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据222",
                                         @"id":@"222",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据223",
                                         @"id":@"223",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     ]
                             },
                         @{
                             @"name":@"数据23",
                             @"id":@"23",
                             @"children":@[
                                     @{
                                         @"name":@"数据231",
                                         @"id":@"231",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据232",
                                         @"id":@"232",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据233",
                                         @"id":@"233",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     ]
                             },
                         ]
                 },
             @{
                 @"name":@"数据3",
                 @"id":@"3",
                 @"children":@[
                         @{
                             @"name":@"数据31",
                             @"id":@"31",
                             @"children":@[
                                     @{
                                         @"name":@"数据311",
                                         @"id":@"311",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据312",
                                         @"id":@"312",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据313",
                                         @"id":@"313",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     ]
                             },
                         @{
                             @"name":@"数据32",
                             @"id":@"32",
                             @"children":@[
                                     @{
                                         @"name":@"数据321",
                                         @"id":@"321",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据322",
                                         @"id":@"322",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据323",
                                         @"id":@"323",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据1131",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1132",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据1133",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     ]
                             },
                         @{
                             @"name":@"数据33",
                             @"id":@"33",
                             @"children":@[
                                     @{
                                         @"name":@"数据331",
                                         @"id":@"331",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据3311",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据3312",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据3313",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据332",
                                         @"id":@"332",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据3321",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据3322",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据3323",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     @{
                                         @"name":@"数据333",
                                         @"id":@"333",
                                         @"children":@[
                                                 @{
                                                     @"name":@"数据3331",
                                                     @"id":@"111",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据3332",
                                                     @"id":@"112",
                                                     @"children":@[]
                                                     },
                                                 @{
                                                     @"name":@"数据3333",
                                                     @"id":@"113",
                                                     @"children":@[]
                                                     },
                                                 ]
                                         },
                                     ]
                             },
                         ]
                 },
             ];
}


@end
